{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "858"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import urllib.request\n",
    "url = 'https://www.w3.org/TR/PNG/iso_8859-1.txt'\n",
    "response = urllib.request.urlopen(url)\n",
    "words = response.read().decode().split()\n",
    "len(words)  # 858"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "import collections\n",
    "word_counter = collections.Counter(words)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LETTER - 114\n",
      "SMALL - 58\n",
      "CAPITAL - 56\n",
      "WITH - 55\n",
      "SIGN - 21\n"
     ]
    }
   ],
   "source": [
    "for word, count in word_counter.most_common(5):\n",
    "    print(word, \"-\", count)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "QUESTION - 2\n",
      "CIRCUMFLEX - 11\n",
      "DIGIT - 10\n",
      "PYTHON - 0\n"
     ]
    }
   ],
   "source": [
    "print(\"QUESTION\", \"-\", word_counter[\"QUESTION\"])\n",
    "print(\"CIRCUMFLEX\", \"-\", word_counter[\"CIRCUMFLEX\"])\n",
    "print(\"DIGIT\", \"-\", word_counter[\"DIGIT\"])\n",
    "print(\"PYTHON\", \"-\", word_counter[\"PYTHON\"])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3+"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
